package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main()  {
	//定义请求路径
	apiUrl := "http://127.0.0.1:8080/req/post"
	//post请求的contentType都是"application/json", 请求参数放在body中
	contentType := "application/json"
	data := `{"name": "wangwu"}`
	//发起请求
	resp, err := http.Post(apiUrl, contentType, strings.NewReader(data))
	if err != nil {
		panic(err)
	}
	//接收响应
	b, _ := io.ReadAll(resp.Body)
	fmt.Println("返回的数据为：", string(b))

}
